package com.sgcc.ln.pmos.e_ln_home.activity;

import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.ToastUtils;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.ln.pmos.arouter.home.HomeArouterPath;
import com.sgcc.ln.pmos.common.base.MvpBaseActivity;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.ln.pmos.e_ln_home.bean.BasicInformationEnterpriseBean;
import com.sgcc.ln.pmos.e_ln_home.bean.FDBasicInformationEnterpriseBean;
import com.sgcc.ln.pmos.e_ln_home.contract.BasicInformationEnterpriseContract;
import com.sgcc.ln.pmos.e_ln_home.contract.FDBasicInformationEnterpriseContract;
import com.sgcc.ln.pmos.e_ln_home.presenter.BasicInformationEnterprisePresenter;
import com.sgcc.ln.pmos.e_ln_home.presenter.FDBasicInformationEnterprisePresenter;

/**
 * 企业基本信息------发电企业
 */
@Route(path = HomeArouterPath.HOME_FDBASICINFORMATIONENTERPRISE)
public class FDBasicInformationEnterpriseActivity extends MvpBaseActivity<FDBasicInformationEnterprisePresenter> implements FDBasicInformationEnterpriseContract.View {

    private TitleBar mTitleBar;
    private TextView mTvIndustrialInfo1;
    private TextView mTvIndustrialInfo2;
    private TextView mTvIndustrialInfo3;
    private TextView mTvIndustrialInfo4;
    private TextView mTvIndustrialInfo5;
    private TextView mTvIndustrialInfo6;
    private TextView mTvIndustrialInfo7;
    private TextView mTvIndustrialInfo8;
    private TextView mTvIndustrialInfo9;
    private TextView mTvIndustrialInfo10;
    private TextView mTvIndustrialInfo11;
    private TextView mTvIndustrialInfo12;
    private TextView mTvIndustrialInfo13;
    private TextView mTvContactInfo1;
    private TextView mTvContactInfo2;
    private TextView mTvContactInfo3;
    private TextView mTvContactInfo4;
    private TextView mTvBasicInfo1;
    private TextView mTvBasicInfo2;
    private TextView mTvBasicInfo3;
    private TextView mTvBasicInfo4;
    private String applyId = "", name = "";

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_fdbasicinformationenterprise;
    }

    @Override
    protected void initViews() {
        super.initViews();
        applyId = getIntent().getStringExtra("guid");
        name = getIntent().getStringExtra("sourceName");
        findViewByIds();
        mPresenter.getData(applyId);
    }

    private void findViewByIds() {
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mTvIndustrialInfo1 = (TextView) findViewById(R.id.tv_IndustrialInfo1);
        mTvIndustrialInfo2 = (TextView) findViewById(R.id.tv_IndustrialInfo2);
        mTvIndustrialInfo3 = (TextView) findViewById(R.id.tv_IndustrialInfo3);
        mTvIndustrialInfo4 = (TextView) findViewById(R.id.tv_IndustrialInfo4);
        mTvIndustrialInfo5 = (TextView) findViewById(R.id.tv_IndustrialInfo5);
        mTvIndustrialInfo6 = (TextView) findViewById(R.id.tv_IndustrialInfo6);
        mTvIndustrialInfo7 = (TextView) findViewById(R.id.tv_IndustrialInfo7);
        mTvIndustrialInfo8 = (TextView) findViewById(R.id.tv_IndustrialInfo8);
        mTvIndustrialInfo9 = (TextView) findViewById(R.id.tv_IndustrialInfo9);
        mTvIndustrialInfo10 = (TextView) findViewById(R.id.tv_IndustrialInfo10);
        mTvIndustrialInfo11 = (TextView) findViewById(R.id.tv_IndustrialInfo11);
        mTvIndustrialInfo12 = (TextView) findViewById(R.id.tv_IndustrialInfo12);
        mTvIndustrialInfo13 = (TextView) findViewById(R.id.tv_IndustrialInfo13);
        mTvContactInfo1 = (TextView) findViewById(R.id.tv_ContactInfo1);
        mTvContactInfo2 = (TextView) findViewById(R.id.tv_ContactInfo2);
        mTvContactInfo3 = (TextView) findViewById(R.id.tv_ContactInfo3);
        mTvContactInfo4 = (TextView) findViewById(R.id.tv_ContactInfo4);
        mTvBasicInfo1 = (TextView) findViewById(R.id.tv_BasicInfo1);
        mTvBasicInfo2 = (TextView) findViewById(R.id.tv_BasicInfo2);
        mTvBasicInfo3 = (TextView) findViewById(R.id.tv_BasicInfo3);
        mTvBasicInfo4 = (TextView) findViewById(R.id.tv_BasicInfo4);

        mTitleBar.setTitle(name + "企业基本信息");
    }

    @Override
    protected FDBasicInformationEnterprisePresenter createPresenter() {
        return new FDBasicInformationEnterprisePresenter();
    }

    @Override
    public void getDataSuccess(FDBasicInformationEnterpriseBean response) {
        if (response.getData().getIpGhFdEnterprise() != null) {
            FDBasicInformationEnterpriseBean.DataBean.IpGhFdEnterpriseBean bean = response.getData().getIpGhFdEnterprise();
            mTvIndustrialInfo1.setText(bean.getCreditCode());
            mTvIndustrialInfo2.setText(bean.getMembersName());
            mTvIndustrialInfo4.setText(bean.getLegalReprName());
            mTvIndustrialInfo5.setText(bean.getEnterpriseType());
            mTvIndustrialInfo6.setText(bean.getFoundDate());

            mTvContactInfo1.setText(bean.getContactName());
            mTvContactInfo2.setText(bean.getOfficePhone());
            mTvContactInfo3.setText(bean.getEmail());
            mTvContactInfo4.setText(bean.getFax());

            String generatorType = "";
            switch (bean.getGeneratorType()) {
                case "010000":
                    generatorType = "水电";
                    break;
                case "020000":
                    generatorType = "火电";
                    break;
                case "030000":
                    generatorType = "核电";//猜测的
                    break;
                case "040000":
                    generatorType = "风电";
                    break;
                case "050000":
                    generatorType = "太阳能";
                    break;
                default:
                    generatorType = "其他";
                    break;
            }

            mTvBasicInfo1.setText(generatorType);
            mTvBasicInfo2.setText(bean.getGeneratorRatedCap());
            mTvBasicInfo3.setText(bean.getGenGroupName());
            mTvBasicInfo4.setText("辽宁");
        }
        if (response.getData().getIpGhBusinessLicenseForm() != null) {
            FDBasicInformationEnterpriseBean.DataBean.IpGhBusinessLicenseFormBean bean = response.getData().getIpGhBusinessLicenseForm();
            mTvIndustrialInfo3.setText(bean.getRegistrationNumber());
            mTvIndustrialInfo7.setText(bean.getRegcapital());
            mTvIndustrialInfo8.setText(bean.getApprovedDate());
            mTvIndustrialInfo9.setText(bean.getRegistrationAuthority());
            mTvIndustrialInfo10.setText(bean.getRegistrationStatus());
            mTvIndustrialInfo11.setText(bean.getAddress());
            mTvIndustrialInfo12.setText(bean.getScope());
            mTvIndustrialInfo13.setText(bean.getBusinessterm());

        }
    }

    @Override
    public void getDataFailed() {
        ToastUtils.showShort("数据请求失败");
    }
}
